#导包
import requests
#设置全局变量
sess = requests.session()
#地址
ip = "192.168.1.7"
#表单上传接口
def file_up_opload():
    #传入文件路径
    path = "d:\\beijing.jpg"
    #打开文件
    with open(path,"rb") as f:
        #file 是fidderler抓包中  name属性的值
        files = {"file":(path,f)}
        rp =sess.request("post","http://"+ip+":8080/pinter/file/api/upload",files=files)
    print(rp.text)

#Ajax上传接口
def file_up_upload2():
    path = "d:\\beijing.jpg"
    #打开文件
    with open(path,"rb") as f:
        #file 是fidderler抓包中  name属性的值
        files = {"file":(path,f)}
        rp =sess.request("post","http://"+ip+":8080/pinter/file/api/upload2",files=files)
    print(rp.text)
#文件下载接口
def file_download():
    params = {"id":1}
    #打开文件
    rp =sess.request("get","http://"+ip+":8080/pinter/file/api/download",params=params)
    print(rp.text)
if __name__ == '__main__':
    file_up_opload()
    file_up_upload2()
    file_download()